<?php
require_once("Config.php");
$messageFlag = '0';
if($_GET['action']=='save'){
  
  $sql = "update news set content='".$_POST['content']."' where newsType=1";
  if(mysql_query($sql)){
    $sessionMessage ="Save content success!";
  }else{
    $sessionMessage = 'Save conent failure!';
  }
  
  $messageFlag='1';
  
  
}
  

$sql = "Select * From news where newsType=1";
$result = mysql_query($sql);
if(!$result){
  echo 'Errow account when query the database.';
  exit();
}
while($row = mysql_fetch_array($result)){
  
  $aboutus_content = $row['content'];
}

?>
<html>
  <head>
    <title>
      Add User !
    </title>
    <link href="css/admin-common.css" rel="stylesheet" type="text/css">
    <script type="text/javascript" src="../js/jquery.js">
    </script>
   
    <script type="text/javascript" src="ckeditor/ckeditor.js"></script>
    
  </head>
  <body>
  <input type="hidden" name='messageFlag' id='messageFlag' value='<?php echo $messageFlag ?>'/>
    <h3>Content Management : About Us</h3>
    <hr/>
    <!--Here is the message from server when page load-->
    <div id="sessionMessage">
      <?php echo $sessionMessage?>
    </div>
    <!--Session Message End-->
    
   
    <!--Add User Form-->
    <form action="?action=save" method="post">
      <textarea class="ckeditor" cols="80" id="content" name="content" rows="10"><?php echo $aboutus_content ?></textarea>
      <p>
        <label>
          <span>&nbsp;</span>
          <button class="btn btn-style-1" type="submit">
            <b><b>Save</b></b>
          </button>
        </label>
      </p>
    </form>
  </body>
  <script type="text/javascript">
    var app={
      init: function() {
      }

    }
  </script>
   <script type="text/javascript" src="js/common.js">
    </script>
</html>
